﻿
<!--#include file="includes/database.asp" -->
<!--#include file="includes/global_varaiable.asp" -->
<!--#include file="theloai_info.asp" -->

<!--#include file="header.asp"-->

<%
nStartRec = 0
nStopRec = 0
nTotalRecs = 0
nRecCount = 0
nRecActual = 0

Const ewSessionMessage = "Message"

sSQL = "SELECT * FROM THELOAI"

' Set up Record Set
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Open sSql, adoCon, 1, 2
nTotalRecs = rs.RecordCount
If nDisplayRecs <= 0 Then ' Display All Records
	nDisplayRecs = nTotalRecs
End If
nStartRec = 1
'SetUpStartRec() ' Set Up Start Record Position
%>

<p><span class="aspmaker">TABLE: THELOAI</span></p>

<%
If Session(ewSessionMessage) <> "" Then
%>
<p><span class="ewmsg"><%= Session(ewSessionMessage) %></span></p>
<%
	Session(ewSessionMessage) = "" ' Clear message
End If
%>

<table class="ewListAdd">
	<tr>
		<td><span class="aspmaker"><a href="theloai_add.asp">Add</a></span></td>
	</tr>
</table>
<p>
<% If nTotalRecs > 0 Then %>
<form method="post">
<table id="ewlistmain" class="ewTable">
	<!-- Table header -->
	<tr class="ewTableHeader">
		<td valign="top"><span>Genre ID (*)</span></td>
		<td valign="top"><span>Genre</span></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
	</tr>
<%

' Avoid starting record > total records
If CLng(nStartRec) > CLng(nTotalRecs) Then
	nStartRec = nTotalRecs
End If

' Set the last record to display
nStopRec = nStartRec + nDisplayRecs - 1

' Move to first record directly for performance reason
nRecCount = nStartRec - 1
If Not rs.Eof Then
	rs.MoveFirst
	rs.Move nStartRec - 1
End If
nRecActual = 0
Do While (Not rs.Eof) And (nRecCount < nStopRec)
	nRecCount = nRecCount + 1
	If CLng(nRecCount) >= CLng(nStartRec) Then
		nRecActual = nRecActual + 1

	' Set row color
	sItemRowClass = " class=""ewTableRow"""
	
	' Display alternate color for rows
	If nRecCount Mod 2 <> 1 Then
		sItemRowClass = " class=""ewTableAltRow"""
	End If
	x_GenreID = rs("GenreID")
	x_Genre = rs("Genre")
%>
	<!-- Table body -->
	<tr<%=sItemRowClass%><%=sListTrJs%>>
		<!-- GiaveID -->
		<td><span>
<% Response.Write x_GenreID %>
</span></td>
		<!-- Dongia -->
		<td><span>
<% Response.Write x_Genre %>
</span></td>
<td><span class="aspmaker"><a href="<% If Not IsNull(x_GenreID) Then Response.Write "theloai_edit.asp?GenreID=" & Server.URLEncode(x_GenreID) Else Response.Write "javascript:alert('Invalid Record! Key is null');" End If %>">Sửa</a></span></td>
<td><span class="aspmaker"><a href="<% If Not IsNull(x_GenreID) Then Response.Write "theloai_delete.asp?GenreID=" & Server.URLEncode(x_GenreID) Else Response.Write "javascript:alert('Invalid Record! Key is null');" End If %>">Xóa</a></span></td>
	</tr>
<%
	End If
	rs.MoveNext
Loop
%>
</table>
</form>
<% End If %>
<%

' Close recordset and connection
rs.Close
Set rs = Nothing
adoCon.Close
Set adoCon = Nothing
%>
<form action="giave_list.asp" name="ewpagerform" id="ewpagerform">
<table border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td nowrap>
<%
If nTotalRecs > 0 Then
	rsEof = (nTotalRecs < (nStartRec + nDisplayRecs))
	PrevStart = nStartRec - nDisplayRecs
	If PrevStart < 1 Then PrevStart = 1
	NextStart = nStartRec + nDisplayRecs
	If NextStart > nTotalRecs Then NextStart = nStartRec
	LastStart = ((nTotalRecs-1)\nDisplayRecs)*nDisplayRecs+1
	%>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="aspmaker">Page&nbsp;</span></td>
<!--first page button-->
	<% If CLng(nStartRec)=1 Then %>
	<td><img src="images/firstdisab.gif" alt="First" width="16" height="16" border="0"></td>
	<% Else %>
	<td><a href="theloai_list.asp?start=1"><img src="images/first.gif" alt="First" width="16" height="16" border="0"></a></td>
	<% End If %>
<!--previous page button-->
	<% If CLng(PrevStart) = CLng(nStartRec) Then %>
	<td><img src="images/prevdisab.gif" alt="Previous" width="16" height="16" border="0"></td>
	<% Else %>
	<td><a href="theloai_list.asp?start=<%=PrevStart%>"><img src="images/prev.gif" alt="Previous" width="16" height="16" border="0"></a></td>
	<% End If %>
<!--current page number-->
	<td><input type="text" name="pageno" value="<%=(nStartRec-1)\nDisplayRecs+1%>" size="4"></td>
<!--next page button-->
	<% If CLng(NextStart) = CLng(nStartRec) Then %>
	<td><img src="images/nextdisab.gif" alt="Next" width="16" height="16" border="0"></td>
	<% Else %>
	<td><a href="theloai_list.asp?start=<%=NextStart%>"><img src="images/next.gif" alt="Next" width="16" height="16" border="0"></a></td>
	<% End If %>
<!--last page button-->
	<% If CLng(LastStart) = CLng(nStartRec) Then %>
	<td><img src="images/lastdisab.gif" alt="Last" width="16" height="16" border="0"></td>
	<% Else %>
	<td><a href="theloai_list.asp?start=<%=LastStart%>"><img src="images/last.gif" alt="Last" width="16" height="16" border="0"></a></td>
	<% End If %>
	<td><span class="aspmaker">&nbsp;of <%=(nTotalRecs-1)\nDisplayRecs+1%></span></td>
	</tr></table>
	<% If CLng(nStartRec) > CLng(nTotalRecs) Then nStartRec = nTotalRecs
	nStopRec = nStartRec + nDisplayRecs - 1
	nRecCount = nTotalRecs - 1
	If rsEOF Then nRecCount = nTotalRecs
	If nStopRec > nRecCount Then nStopRec = nRecCount %>
	<span class="aspmaker">Records <%= nStartRec %> to <%= nStopRec %> of <%= nTotalRecs %></span>
<% Else %>
	<% If sSrchWhere = "0=101" Then %>
	<span class="aspmaker"></span>
	<% Else %>
	<span class="aspmaker">No records found</span>
	<% End If %>
<% End If %>
		</td>
	</tr>
</table>
</form>

<!--#include file="footer.asp"-->
